import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class studentTest {



    //    测依赖注入之setter注入
    @Test
    public void Tst01(){
        ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");
        Student studentTwo = (Student) ioc.getBean("studentTwo");
        System.out.println(studentTwo);

    }


    //测试通过Java方式进行注入
    @Test
    public void Test02(){
    ApplicationContext ioc = new AnnotationConfigApplicationContext(Student.class);
    Student bean = ioc.getBean(Student.class);
    bean.setAge(18);
    bean.setName("Goddard");
    bean.setSid(2022);
    System.out.println(bean);
    }

    //测试通过注解方式注入
    @Test
    public void Test03(){
        ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");
        Student bean = ioc.getBean(Student.class);
        System.out.println(bean);

    }

}
